package com.lgy.ms.core.enums;

import com.google.common.collect.Maps;

import java.util.Map;

/**
 * @author Gylin
 * 常用字典
 */
public enum CommonEnum {

    /**
     * 是/否
     */
    Yes("Y", "是"),
    No("N", "否"),
    /**
     * 启用/禁用
     */
    Disable("0", "禁用"),
    Enable("1", "启用"),
    /**
     * 正常/删除
     */
    Delete("1", "删除"),
    Normal("0", "正常")
    ;

    public String value;
    public String desc;

    CommonEnum(String value, String desc) {
        this.value = value;
        this.desc = desc;
    }

    public String getValue() {
        return value;
    }

    public String getDesc() {
        return desc;
    }

    static Map<Object, CommonEnum> enumMap = Maps.newHashMap();

    static {
        for (CommonEnum type : CommonEnum.values()) {
            enumMap.put(type.getDesc(), type);
        }
    }

    public static CommonEnum getEnum(String desc) {
        return enumMap.get(desc);
    }
}
